all files / internal/ focusRipple.vue

14.29% Statements 2/14
0% Branches 0/2
0% Functions 0/4
7.69% Lines 1/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51                                                                                                     
//
//
//
//
//
//
 
export default {
  props: {
    color: {
      type: String,
      default: ''
    },
    opacity: {
      type: Number
    }
  },
  computed: {
    style () {
      return {
        color: this.color,
        opacity: this.opacity
      }
    }
  },
  methods: {
    setRippleSize () {
      const el = this.$refs.innerCircle
      const height = el.offsetHeight
      const width = el.offsetWidth
      const size = Math.max(height, width)
 
      let oldTop = 0
 
      if (el.style.top.indexOf('px', el.style.top.length - 2) !== -1) {
        oldTop = parseInt(el.style.top)
      }
 
      el.style.height = `${size}px`
      el.style.top = `${(height / 2) - (size / 2) + oldTop}px`
    }
  },
  mounted () {
    this.setRippleSize()
  },
  updated () {
    this.setRippleSize()
  }
}